Previous Topic

Next Topic

HttpRequest Object

The HttpRequest Object can be used to interact with a server via http. HTTP works as a request-response protocol between Accredo and the server.

HttpRequest Object has the following Methods:

ClearLog

Clear the HttpRequest log.

Get

Requests data from the server.

GetLog

GetLog returns a readonly string property.

Note: The log doesn't differentiate between the types of messages (i.e connection status etc vs response) so it will contain everything that the ShowLog window would normally contain.

Patch

Sends data to the server to update information. Patch will only update fields specified in the json body request.

Post

Sends data to the server to create or update information. Using a Post request more than once can result in multiple instances being created. Post must be used to insert where a key is system generated, such as for Documents or Transactions.

PostForm

Takes a HttpFormBuilder object and posts it to the server.

Put

Sends data to the server to create or update information. This is different from the Post method, as using this more than once will always have the same result.

Put requests must include the entity's ID in the URL. If the ID is found it will be updated, otherwise a new entity will be inserted.

For updates, any fields not specified in the json body request will be cleared. It is recommended to use Patch for updates.

SetRequestHeader

Takes a Header string and a Value string, and sets the Header to the Value.

ShowLog

Displays the HttpRequest log with details of all requests processed.

UseBasicAuthentication

Takes a UserName and Password and authenticates on the server.

HttpRequest Object has the following Properties:

Accept

The Accept request header: the content types the script accepts in the response. Defaults to */*.

CertificateFile

The client certificate file (.crt) to send when the server requires a client certificate. Use with KeyFile and PassPhrase.

ConnectTimeout

The number of milliseconds to wait for the connection to the server.

ContentEncoding

The Content-Encoding request header.

ContentType

The Content-Type request header, e.g. application/json.

DisableURLEncoding

True, the URL is sent as set. Use this when the URL is already encoded.

False, (default) the URL is encoded before it is sent.

KeyFile

The private key file (.key) for the CertificateFile.

Logging

True, requests and responses are recorded in the log that ShowLog and GetLog return.

False, (default) nothing is recorded.

PassPhrase

The passphrase for the KeyFile.

ReadTimeout

The number of milliseconds to wait for the server to respond.

ResponseCode

The HTTP status code of the last response, e.g. 200 or 404. Read-only.

ResponseContentLength

The length in bytes of the last response, as given by the server. Read-only.

ResponseContentType

The content type of the last response. Read-only.

ResponseFilename

The file to save the response to. When this is set, the request method returns an empty string.

Use it for an audio, image, video or PDF response. When ResponseFilename is not set, the request method returns an empty string for these content types.

ResponseOK

True when the ResponseCode is 200 to 299. Read-only.

ResponseText

The status line of the last response, e.g. HTTP/1.1 200 OK. The response body is the value the request method returns. Read-only.

RootCertificateFile

The root certificate file (.crt) for the client certificate chain.

SSLVersion

The minimum TLS version for the connection:

  • 3 TLS 1.0
  • 4 TLS 1.1
  • 5 TLS 1.2 (default)
  • 6 TLS 1.3

When Validate HTTPS server certificates is selected in System Settings - General tab, a value lower than 5 is raised to TLS 1.2.

URL

The URL of the request. A request without a URL fails with the error URL not set.

UserAgent

The User-Agent request header. If this is not set, Accredo sends a web browser user agent.

ValidateServerCertificate

True, the server certificate is checked against the Windows trusted root certificates, and the server name must match the certificate.

False, (default) the server certificate is not checked.

When Validate HTTPS server certificates is selected in System Settings, every request checks the server certificate, whatever this property is set to. That setting is selected by default.

Note: Log output from the object in scripts called from an event or the PlayScript endpoint via the Web Service is not returned but may be logged using User logging. User logging may be enabled in Web Service Monitor > Settings > Logging tab, and viewed under Web Service Log File Viewer.

See Also

MaxBasic Objects

Book Contents

Book Index